<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('货位管理列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label class="is-required">仓库：</label>
                            <select id="warehouseId" name="warehouseId" th:with="type=${session.warehouse}">
                                <!--								<option   th:value="${session.warehouseId}" th:text="${@dict.getDictLabel('${session.warehouseId}')}"></option>-->
                                <option th:each="dict : ${type}" th:text="${dict.warehouseName}" th:value="${dict.warehouseId}"></option>
                            </select>
                        </li>
                        <li>
                            <label>货位编号：</label>
                            <input type="text" name="cargoSpaceId"/>
                        </li>

                        <li>
                            <label>排：</label>
                            <input type="text" name="thePlatoon"/>
                        </li>
                        <li>
                            <label>列：</label>
                            <input type="text" name="theColumn"/>
                        </li>
                        <li>
                            <label>层：</label>
                            <input type="text" name="theFloor"/>
                        </li>

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search('formId','bootstrap-table')"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset('formId','bootstrap-table')"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <!--                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="device:space:add">-->
            <!--                    <i class="fa fa-plus"></i> 添加-->
            <!--                </a>-->
            <!--                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="device:space:edit">-->
            <!--                    <i class="fa fa-edit"></i> 修改-->
            <!--                </a>-->
            <!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="device:space:remove">-->
            <!--                    <i class="fa fa-remove"></i> 删除-->
            <!--                </a>-->
            <!--<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="device:space:export">-->
                <!--<i class="fa fa-download"></i> 导出-->
            <!--</a>-->
        </div>
        <div class="col-sm-12 select-table table-bordered">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('device:space:edit')}]];
    var removeFlag = [[${@permission.hasPermi('device:space:remove')}]];
    var warehouseIdDatas = [[${@dict.getType('is_house')}]];
    var statusDatas = [[${@dict.getType('space_status')}]];
    var lockedDatas = [[${@dict.getType('space_locked')}]];
    var issDoubleDatas = [[${@dict.getType('space_ds')}]];
    var cargoSpaceLogoDatas = [[${@dict.getType('space_ds')}]];
    var cargoAreaDatas = [[${@dict.getType('cargo_area')}]];
    var prefix = ctx + "stock/stock";

    $(function() {
        var options = {
            url: prefix + "/selectCargolist?status="+1+"&wahousehouseId="+$("#warehouseId").val(),
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "货位管理",
            pageSize: 10,
            clickToSelect: false,//是否启用点击选中行
            uniqueId:"cargoSpaceId",//表主键(用于修改和删除)
            sortName:"cargoSpaceId",//必加排序 sortOrder: "asc"默认
            columns: [
                {
                    halign: 'center',
                    align:'center',
                    checkbox: true
                },


                {
                    field: 'cargoSpaceId',
                    title: '货位编号',
                    halign: 'center',
                    align:'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'cargoSpaceName',
                    title: '货位名称',
                    halign: 'center',
                    align:'center',
                    sortable: true,
                    visible: true
                },

                // {
                //     field: 'theType',
                //     title: '类型',
                //     halign: 'center',
                //     align:'center',
                //     sortable: true,
                //     visible: false
                // },
                // {
                //     field: 'theTypeName',
                //     title: '类型名',
                //     halign: 'center',
                //     align:'center',
                //     sortable: true,
                //     visible: true
                // },

                {
                    field: 'thePlatoon',
                    title: '排',
                    halign: 'center',
                    align:'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'theColumn',
                    title: '列',
                    halign: 'center',
                    align:'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'theFloor',
                    title: '层',
                    halign: 'center',
                    align:'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'status',
                    title: '状态',
                    halign: 'center',
                    align:'center',
                    sortable: true,
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(statusDatas, value);
                    }
                },
                {
                    field: 'warehouseId',
                    title: '所属仓库',
                    halign: 'center',
                    align:'center',
                    sortable: true,
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(warehouseIdDatas, value);
                    }
                },
                {
                    field: 'roadwayId',
                    title: '所属巷道',
                    halign: 'center',
                    align:'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'cargoAreaId',
                    title: '所属货区',
                    halign: 'center',
                    align:'center',
                    sortable: true,
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(cargoAreaDatas, value);
                    }
                },
                {
                    field:'locked',
                    title: '是否锁定',
                    align: 'center',
                    formatter: function (value, row, index) {
                        if(value=='Y'){
                            return "锁定"
                        }else if(value=='N'){
                            return "未锁定"
                        }

                    }
                },

                {
                    field: 'cargoHight',
                    title: '货位高度',
                    halign: 'center',
                    align:'center',
                    sortable: true,
                    visible: true
                },
                // {
                //     field: 'issDouble',
                //     title: '是否双伸',
                //     halign: 'center',
                //     align:'center',
                //     sortable: true,
                //     formatter: function(value, row, index) {
                //        return $.table.selectDictLabel(issDoubleDatas, value);
                //     }
                // },
                // {
                //     field: 'groupCodingNo',
                //     title: '同组货位',
                //     halign: 'center',
                //     align:'center',
                //     sortable: true,
                //     visible: false
                // },
                // {
                //     field: 'groupCoding',
                //     title: '同组货位编码',
                //     halign: 'center',
                //     align:'center',
                //     sortable: true,
                //     visible: false
                // },
                // {
                //     field: 'cargoSpaceLogo',
                //     title: '双伸标识',
                //     halign: 'center',
                //     align:'center',
                //     sortable: true,
                //     formatter: function(value, row, index) {
                //        return $.table.selectDictLabel(cargoSpaceLogoDatas, value);
                //     }
                // },
                {
                    field: 'thisCargoArea',
                    title: '当前货区',
                    halign: 'center',
                    align:'center',
                    sortable: true,
                    visible: false
                },
                ]
        };
        $.table.init(options);
    });
    /* 锁定状态显示 */
    function lockdeTools(row) {
        if (row.locked == "N") {
            return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="disable(\'' + row.cargoSpaceId + '\')"></i> ';
        } else {
            return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="enable(\'' + row.cargoSpaceId + '\')"></i> ';
        }
    }
    /* 设备仓库管理-锁定 */
    function disable(cargoSpaceId) {
        $.modal.confirm("是否将货位锁定？", function () {
            $.operate.post(prefix + "/changeLocked", {"cargoSpaceId": cargoSpaceId, "locked": "Y"});
        })
    }

    /* 设备仓库管理解锁 */
    function enable(cargoSpaceId) {
        $.modal.confirm("是否将货位解锁？", function () {
            $.operate.post(prefix + "/changeLocked", {"cargoSpaceId": cargoSpaceId, "locked": "N"});
        })
    }


    function result() {
        var row = $("#bootstrap-table").bootstrapTable('getSelections');
        return row;
    }

</script>
</body>
</html>